home *** CD-ROM | disk | FTP | other *** search
- /**
- * Scout - The Amiga System Monitor
- *
- *------------------------------------------------------------------
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * You must not use this source code to gain profit of any kind!
- *
- *------------------------------------------------------------------
- *
- * @author Andreas Gelhausen
- * @author Richard Körber <rkoerber@gmx.de>
- */
-
-
-
- #include "system_headers.h"
-
- static APTR intmoretext0,intmoretext1,intmoretext2,intmoretext3;
-
- static APTR IntPool = NULL;
-
- static UBYTE *intType[] = {
- "TBE (ser.transmit buffer empty)",
- "DSKBLK (disk block complete)",
- "SOFTINT (software interrupt)",
- "PORTS (external INT2 & CIAA)",
- "COPPER (graphics coprocessor)",
- "VERTB (vertical blank interval)",
- "BLITTER (blitter finished)",
- "AUDIO0 (audio channel 0)",
- "AUDIO1 (audio channel 1)",
- "AUDIO2 (audio channel 2)",
- "AUDIO3 (audio channel 3)",
- "RBF (ser. receive buffer full)",
- "DSKSYNC (disk sync patt. found)",
- "EXTER (external INT6 & CIAB)",
- "INTEN (special (master enable))",
- "NMI (non-maskable interrupt)"
- };
-
- static UBYTE *intTypeShort[] = {
- "Serial Out",
- "Disk Block",
- "SoftInt",
- "INT2/CIAA",
- "Copper",
- "Vertical Blank",
- "Blitter",
- "Audio 0",
- "Audio 1",
- "Audio 2",
- "Audio 3",
- "Serial In",
- "Disk Sync",
- "INT6/CIAB",
- "INTEN",
- "NMI"
- };
-
- __asm __saveds LONG intlist_dspfunc(register __a2 char **array, register __a1 struct IntEntry *intentry, register __a0 struct Hook *hook)
- {
- if (intentry) {
- *array++ = intentry->int_address;
- *array++ = intentry->int_name;
- *array++ = intentry->int_pri;
- *array++ = intentry->int_data;
- *array++ = intentry->int_code;
- *array++ = intentry->int_num;
- *array++ = intentry->int_kind;
- *array = NULL;
- } else {
- *array++ = ESC "bAddress";
- *array++ = ESC "bln_Name";
- *array++ = ESC "bln_Pri";
- *array++ = ESC "bis_Data";
- *array++ = ESC "bis_Code";
- *array++ = ESC "bInterrupt";
- *array++ = ESC "bIntType";
- *array = NULL;
- }
- return(0);
- }
-
- struct Hook intlist_dsphook = {
- {NULL, NULL},
- (ULONG (* )())intlist_dspfunc,
- NULL, NULL
- };
-
- void FreeInterrupts (void)
- {
- MyFreePoolStructs (&IntPool, inttext, NULL, intlist);
- }
-
- APTR GetInterrupts (int si_job, char *name, struct IntEntry **first) {
- struct IntVector *intvec;
- struct Interrupt *intr,*intradr;
- char *mark;
- struct Node *intnode;
- struct IntEntry *intentry,*previous = NULL;
- int i;
-
- int intcnt = 0;
- if (first)
- *first = 0;
-
- if (!IntPool) IntPool = tbCreatePool(MEMF_CLEAR, 4096, 4096);
-
- IsHex (name, (long *) &intradr);
-
- if (clientstate) {
- if (SendDaemon ("GetIntList")) {
- while ((intentry = tbAllocPooled(IntPool, sizeof(struct IntEntry))) \
- && (ReceiveDecodedEntry ((UBYTE *) intentry, sizeof (struct IntEntry)))) {
- IsHex (intentry->int_address, (long *) &intentry->int_adr);
-
- if (! *first)
- *first = intentry;
- if (previous)
- previous->int_next = intentry;
-
- intcnt++;
- previous = intentry;
- }
- }
- } else {
- for (i = 0; i <= 15; i++) {
- if (intvec = (struct IntVector *) &(SysBase->IntVects[i])) {
- if (intnode = intvec->iv_Node) {
- if ((si_job == SI_LIST) && (intvec->iv_Code) && (intentry = tbAllocPooled(IntPool, sizeof(struct IntEntry)))) {
- if (! *first)
- *first = intentry;
- if (previous)
- previous->int_next = intentry;
-
- intentry->int_adr = (char *) intnode;
-
- if (points2ram((APTR) intvec->iv_Code)) {
- _sprintf (intentry->int_code, HELL "$%08lx", intvec->iv_Code);
- } else {
- _sprintf (intentry->int_code, "$%08lx", intvec->iv_Code);
- }
- _sprintf (intentry->int_address, "$%08lx", intnode);
- strncpy (intentry->int_name, nonetest (intnode->ln_Name), NODENAMELENGTH);
- _sprintf (intentry->int_pri, "%4ld ", intnode->ln_Pri);
- _sprintf (intentry->int_data, "$%08lx", intvec->iv_Data);
- strncpy(intentry->int_num, intTypeShort[i], 31);
- strcpy (intentry->int_kind, "Handler");
- intentry->int_number = i;
-
- intcnt++;
- previous = intentry;
- } else if ((si_job == SI_FIND) && (! stricmp (name, intnode->ln_Name))) {
- return ((APTR) intnode);
- } else if ((si_job == SI_REMOVE) && (! stricmp (name, intnode->ln_Name))) {
- return (NULL);
- }
- /*
- if (intvec = (struct IntVector *) intnode->ln_Succ) {
- intnode = intvec->iv_Node;
- }
- */
- } else if ((mark = (char *) intvec->iv_Data) && (mark != (char *) -1)) {
- intr = (struct Interrupt *) ((struct Interrupt *) mark)->is_Node.ln_Succ;
- mark += 4;
-
- while ((intr) && (intr != (struct Interrupt *) mark)) {
- if ((si_job == SI_LIST) && (intentry = tbAllocPooled(IntPool, sizeof(struct IntEntry)))) {
- if (! *first)
- *first = intentry;
- if (previous)
- previous->int_next = intentry;
-
- intentry->int_adr = (char *) intr;
-
- if (points2ram((APTR) intr->is_Code)) {
- _sprintf (intentry->int_code, HELL "$%08lx", intr->is_Code);
- } else {
- _sprintf (intentry->int_code, "$%08lx", intr->is_Code);
- }
- _sprintf (intentry->int_address, "$%08lx", intr);
- strncpy (intentry->int_name, nonetest (intr->is_Node.ln_Name), NODENAMELENGTH);
- _sprintf (intentry->int_pri, "%4ld ", intr->is_Node.ln_Pri);
- _sprintf (intentry->int_data, "$%08lx", intr->is_Data);
- strncpy (intentry->int_num, intTypeShort[i], 31);
- strcpy (intentry->int_kind, "Server");
- intentry->int_number = i;
-
- intcnt++;
- previous = intentry;
- } else if ((si_job == SI_FIND) && (! stricmp (name, intr->is_Node.ln_Name))) {
- return ((APTR) intr);
- } else if ((si_job == SI_REMOVE) && (! stricmp (name, intr->is_Node.ln_Name))) {
- RemIntServer (i, intr);
- return ((APTR) intr);
- }
- intr = (struct Interrupt *) intr->is_Node.ln_Succ;
- }
- }
- }
- }
- }
- if (si_job == SI_LIST) {
- return ((APTR) intcnt);
- }
- return (NULL);
- }
-
- void PrintInterrupts (char *filename) {
- int i=1;
- BPTR handle;
- struct IntEntry *entryp = NULL;
-
- handle = HandlePrintStart (filename);
- if ((handle) && (PrintOneLine (handle, "\n Address Pri Data Code NUM IntType Name\n\n"))) {
- if (! WI_Interrupts) {
- i = (int) GetInterrupts (SI_LIST, NULL, &entryp);
- }
- if (i) {
- for (i=0;;i++) {
- if (WI_Interrupts)
- DoMethod (intlist,MUIM_List_GetEntry,i,&entryp);
- if (!entryp) break;
-
- if (entryp->int_code[0] != '$')
- strcpy (tmpstr, entryp->int_code+2);
- else
- strcpy (tmpstr, entryp->int_code);
-
- _sprintf (tmpstr2, " %s %s%s %s %s%-7.7s %s\n", entryp->int_address, entryp->int_pri, entryp->int_data, tmpstr, entryp->int_num, entryp->int_kind, entryp->int_name);
- if (! (PrintOneLine (handle, tmpstr2)))
- break;
-
- if (! WI_Interrupts)
- entryp = entryp->int_next;
- }
- }
- }
- HandlePrintStop();
- }
-
- void ShowInterrupts (void) {
- struct IntEntry *intr;
-
- ApplicationSleep();
- set (intlist,MUIA_List_Quiet,TRUE);
- set (BT_IntRemove, MUIA_Disabled, TRUE);
- set (BT_IntMore, MUIA_Disabled, TRUE);
-
- FreeInterrupts();
- intcnt = (int) GetInterrupts (SI_LIST, NULL, &intr);
-
- while (intr) {
- InsertBottomEntry (intlist, (APTR *) &intr);
- intr = intr->int_next;
- }
-
- SetCountText (intcount, intcnt);
- AwakeApplication();
- set (intlist,MUIA_List_Quiet,FALSE);
- }
-
- void SendIntList (void) {
- struct IntEntry *intr;
-
- FreeInterrupts();
- intcnt = (int) GetInterrupts (SI_LIST, NULL, &intr);
-
- while (intr) {
- SendEncodedEntry ((UBYTE *) intr, sizeof (struct IntEntry));
- intr = intr->int_next;
- }
- FreeInterrupts();
- }
-
- void GetIntMore (struct IntEntry *intr) {
- unsigned char *title = "INTERRUPT: ";
- struct WinFree *ptr;
-
- if (ptr = AllocWinFree()) {
- ptr->wf_Window = (APTR) WindowObject,
-
- // MUIA_Window_SizeGadget, FALSE,
- MUIA_HelpNode, InterruptsText,
- MUIA_Window_ID, MakeDetailID('.','I','N','T'),
- WindowContents, HGroup,
- Child, VGroup, MUIA_Group_SameWidth, TRUE,
- Child, MyLabel2 ("Name:"),
- Child, MyLabel2 ("Address:\nPri:\nType:"),
- Child, MyLabel2 ("IntName:"),
- End,
- Child, VGroup, MUIA_Group_SameWidth, TRUE,
- Child, intmoretext0 = MyTextObject(),
- Child, HGroup,
- Child, intmoretext1 = MyTextObject2(),
- Child, MyLabel ("Data:\nCode:\nIntType:"),
- Child, intmoretext2 = MyTextObject2(),
- End,
- Child, intmoretext3 = MyTextObject(),
- End,
- End, End;
-
- if (ptr->wf_Window) {
- MySetContents (intmoretext1, ESC "r%s\n" ESC "c%ld\n" ESC "c%s", intr->int_address, ((struct Node *) intr->int_adr)->ln_Pri, GetNodeType (((struct Node *) intr->int_adr)->ln_Type));
- MySetContents (intmoretext2, ESC "r%s\n%s\n" DUNKEL ESC "c%s", intr->int_data, intr->int_code, intr->int_kind);
- MySetContents (intmoretext3, intType[intr->int_number]);
-
- HandleWindowOpen (ptr, title, intr->int_name);
- MySetContents (intmoretext0, intr->int_name);
- HandleWindowClose (ptr);
- }
- }
- }
-
-
- char interrupts_title[WINDOWTITLELEN];
-
- void InterruptsWindow (BOOL state) {
- if (state) {
- if (WI_Interrupts) {
- ShowInterrupts();
- } else {
- WI_Interrupts = WindowObject,
- MUIA_Window_Title, MyGetWindowTitle (interrupts_title, "INTERRUPTS"),
- MUIA_HelpNode, InterruptsText,
- MUIA_Window_ID, MakeListID('I','N','T','E'),
- WindowContents, VGroup,
- Child, intlist = MyListviewObject ("COL=0 DELTA=8,COL=1 DELTA=8,COL=2 DELTA=8 P=\33r,COL=3 DELTA=8,COL=4 DELTA=8,COL=5 DELTA=8,COL=6",&intlist_dsphook),
- Child, MyBelowListview (&inttext, &intcount),
- Child, MyVSpace(2),
- Child, HGroup, MUIA_Group_SameSize, TRUE,
- Child, BT_IntUpdate = KeyButtonA (UpdateText,ID_INTUPDATE),
- Child, BT_IntPrint = KeyButtonA (PrintText ,ID_INTPRINT),
- Child, BT_IntRemove = KeyButtonA (RemoveText,ID_INTREMOVE),
- Child, BT_IntMore = KeyButtonA (MoreText ,ID_INTMORE),
- Child, BT_IntExit = KeyButtonA (ExitText ,ID_INTEXIT),
- End,
- End, End;
-
- DoMethod (AP_Scout,OM_ADDMEMBER,WI_Interrupts);
- DoMethod (WI_Interrupts,MUIM_Window_SetCycleChain,intlist,BT_IntUpdate,BT_IntPrint,BT_IntRemove,BT_IntMore,BT_IntExit,NULL);
-
- SetCloseRequest (WI_Interrupts,ID_INTEXIT);
- SetListActive (intlist,ID_INTLV_ACTIVE);
- SetListviewDoubleClick (intlist,ID_INTMORE);
-
- ShowInterrupts();
-
- SetWindowOpen (WI_Interrupts,intlist,ID_INTEXIT);
- }
- } else if ((! state) && (WI_Interrupts)) {
- SetWindowClose (WI_Interrupts,TRUE);
-
- FreeInterrupts();
-
- DoMethod (AP_Scout,OM_REMMEMBER,WI_Interrupts);
- MUI_DisposeObject (WI_Interrupts);
- WI_Interrupts = NULL;
- intlist = NULL;
- }
- }
-
-